#include<stdlib.h>
namespace UNINIT_HEAP_MUST {

	namespace bad_1 {
		typedef struct {
			int x;
		} S1;

		typedef struct {
			S1* ptr;
		} S2;

		void foo(S1* ptr) {
			int k = ptr ? ptr->x : -1;
		}

		int main() {
			S2* ps = (S2*)malloc(sizeof(S2));
			if (ps != NULL) {
				foo(ps->ptr);
				free(ps);
			}
			return 0;
		}

	
	}

	namespace bad_2 {

		typedef struct {
			int x, y;
		} S1;

		int foo(S1* ptr) {
			return ptr->x * ptr->y;
		}

		int main() {
			S1* ps = (S1*)malloc(sizeof(S1));
			if (ps != NULL) {
				foo(ps);
				free(ps);
			}
		}
	}


	namespace good_1 {

		typedef struct {
			int x;
		} S1;

		typedef struct {
			S1* ptr;
		} S2;

		void foo(S1* ptr) {
			int k = ptr ? ptr->x : -1;
		}

		int main() {
			S2* ps = (S2*)calloc(1, sizeof(S2));
			if (ps != NULL) {
				foo(ps->ptr);
				free(ps);
			}
			return 0;
		}
	}



	namespace good_2 {

		typedef struct {
			int x, y;
		} S1;

		int foo(S1* ptr) {
			return ptr->x * ptr->y;
		}

		int main() {
			S1* ps = (S1*)malloc(sizeof(S1));
			if (ps != NULL) {
				ps->x = 32, ps->y = 64;
				foo(ps);
				free(ps);
			}
		}
	}
}